import request from '@/utils/request'

// 登录方法
export function login(username, password, captcha, captchaKey) {
  const data = {
    account:username,
    password,
    captchaKey,
    loginDeviceType: 1,
    captcha,captcha
  }
  return request({
    url: '/base/auth/user/login',
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo(data) {
  return request({
    url: '/base/auth/user/token/detail/'+data,
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/base/auth/user/logout',
    method: 'post'
  })
}

// 判断是否为默认密码
export function defaultPas(data) {
  return request({
    url: '/base/auth/user/getDefaultPasswordIsUpdateUserByCodes',
    method: 'get',
    params: data,
  })
}

// 修改密码
export function updateUserPwd(data, token) {
  return request({
    url: '/base/auth/user/password/update/byCode',
    method: 'post',
    data: data,
    headers: {
      token: token
    }
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/base/auth/user/login/captcha',
    method: 'get',
    timeout: 20000
  })
}

// 获取用户详细信息
// /
export function getUserInfo(id) {
  return request({
    url: '/base/auth/user/getUser/'+id,
    method: 'get',
    timeout: 20000
  })
}
// /
export function resetLogin(data) {
  return request({
    url: '/base/auth/user/password/reset',
    method: 'post',
    data: data
  })
}
// 用户模糊搜索分页 并附带组织机构信息
export function getOrgList() {
  return request({
    url: '/base/org/tree',
    method: 'get',
  });
}

// 查询角色列表
export function rolegetList(query) {
  return request({
    url: '/base/auth/role/list',
    method: 'get',
    params: query
  })
}

// 查询角色列表
export function register(data) {
  return request({
    url: '/base/auth/user/register',
    method: 'post',
    data: data
  })
}
